package com.SouthernWall_404.age_tool.common.world.block.RedStoneComponent.GateBlock;

import com.SouthernWall_404.age_tool.common.world.block.RedStoneComponent.AbstractRedStoneOutputBlock;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.DirectionProperty;

public abstract class AbstractLogicGateBlock extends AbstractRedStoneOutputBlock {
    public static final DirectionProperty FACING = AbstractRedStoneOutputBlock.FACING;
    public static final BooleanProperty POWERED = AbstractRedStoneOutputBlock.POWERED;

    public AbstractLogicGateBlock(Properties properties) {
        super(properties);
        this.registerDefaultState(this.stateDefinition.any()
                .setValue(FACING, Direction.NORTH)
                .setValue(POWERED, Boolean.FALSE));
    }

    @Override
    protected int getDelay(BlockState blockState) {
        return 0;
    }

    @Override
    protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
        builder.add(FACING, POWERED);
//        super.createBlockStateDefinition(builder);
    }

    @Override
    public int getOutput(Level level, BlockPos blockPos, BlockState blockState) {
        int inputA = getInputSignal(level, blockPos, blockState);
        int inputB = getAlternateSignal(level, blockPos, blockState);
        return getLogicalOutput(inputA, inputB);
    }

    abstract int getLogicalOutput(int a, int b);
}